import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router =  new Router({
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/modelmenus',
      name: 'modelmenus',
      component: () => import(/* webpackChunkName: "modelmenus" */'@/views/set/wellset/modelmenus.vue'),
      meta: { title: '曲线查看' }
    },
    {
      path: '/',
      name: 'home',
      component: () => import(/* webpackChunkName: "homepage" */'@/views/homepage.vue'),
      meta: { title: '主页' },
      children: [
        {
          path: '/admin',
          name: 'admin',
          component: () => import(/* webpackChunkName: "admin" */'@/views/other/admin.vue'),
          meta: { title: '个人中心' }
        },
        {
          path: '/helpcenter',
          name: 'helpCenter',
          component: () => import(/* webpackChunkName: "helpCenter" */'@/views/other/helpCenter.vue'),
          meta: { title: '帮助中心' }
        },
        //bigShow
        {
          path: '/hq',
          name:'hq',
          component: () => import(/* webpackChunkName: "hq" */'@/views/bigShow/hq.vue'),
          meta: { title: '总部大屏' }
        },
        {
          path: '/base',
          name:'base',
          component: () => import(/* webpackChunkName: "base" */'@/views/bigShow/base.vue'),
          meta: { title: '基地大屏' }
        },
        {
          path: '/sea',
          name:'sea',
          component: () => import(/* webpackChunkName: "sea" */'@/views/bigShow/sea.vue'),
          meta: { title: '海上大屏' }
        },
        {
          path: '/administrator',
          name:'administrator',
          component: () => import(/* webpackChunkName: "administrator" */'@/views/bigShow/administrator.vue'),
          meta: { title: '管理员大屏' }
        },
        //well
        {
          path: '/welldata',
          name:'welldata',
          component: () => import(/* webpackChunkName: "welldata" */'@/views/welllist/welldata.vue'),
          meta: { title: '井列表' },
        },
        {
          path: '/welldata/:menuName',
          name:'welldata',
          component: () => import(/* webpackChunkName: "welldata" */'@/views/welllist/welldata.vue'),
          meta: { title: '井列表' },
        }
      ]
    },
    {
      path: '/',
      name: 'MyCollection',
      component: () => import(/* webpackChunkName: "homepage" */'@/views/homepage.vue'),
      meta: { title: '我的收藏' },
      children: [
        //collection
        {
          path: '/collection',
          name:'collection',
          component: () => import(/* webpackChunkName: "collection" */'@/views/collection/collection.vue'),
          meta: { title: '井收藏' }
        },   
      ]
    },
    //set
    {
      path: '/',
      name: 'Configuration',
      component: () => import(/* webpackChunkName: "homepage" */'@/views/homepage.vue'),
      meta: { title: '配置中心' },
      children: [
        //set
        {
          path: '/templates',
          name: 'templates',
          component: () => import(/* webpackChunkName: "templates" */'@/views/set/templates/templates.vue'),
          meta: { title: '模板配置'}
        },
        {
          path: '/curve',
          name:'curve',
          component: () => import(/* webpackChunkName: "curve" */'@/views/set/curve.vue'),
          meta: { title: '曲线配置' }
        },
        {
          path: '/area',
          name:'area',
          component: () => import(/* webpackChunkName: "area" */'@/views/set/area.vue'),
          meta: { title: '区域配置' }
        },
        {
          path: '/block',
          name:'block',
          component: () => import(/* webpackChunkName: "block" */'@/views/set/block.vue'),
          meta: { title: '区块配置' }
        },
        {
          path: '/curveunit',
          name:'curveunit',
          component: () => import(/* webpackChunkName: "curve" */'@/views/set/curveunit.vue'),
          meta: { title: '曲线单位' }
        },
        {
          path: '/server',
          name:'server',
          component: () => import(/* webpackChunkName: "server" */'@/views/set/server.vue'),
          meta: { title: '服务器配置' }
        },
        {
          path: '/platform',
          name:'platform',
          component: () => import(/* webpackChunkName: "platform" */'@/views/set/platform.vue'),
          meta: { title: '平台配置' }
        },
        {
          path: '/wellset',
          name:'wellset',
          component: () => import(/* webpackChunkName: "wellset" */'@/views/set/wellset/wellset.vue'),
          meta: { title: '井配置' }
        },
        {
          path: '/company',
          name:'company',
          component: () => import(/* webpackChunkName: "company" */'@/views/set/company.vue'),
          meta: { title: '作业公司' }
        },
        {
          path: '/help',
          name:'help',
          component: () => import(/* webpackChunkName: "help" */'@/views/set/help.vue'),
          meta: { title: '帮助中心配置' }
        },     
      ]
    },
    //Management
    {
      path: '/',
      name: 'Management',
      component: () => import(/* webpackChunkName: "homepage" */'@/views/homepage.vue'),
      meta: { title: '管理中心' },
      children: [
          {
            path: '/wellcondition',
            name:'wellcondition',
            component: () => import(/* webpackChunkName: "wellstatus" */'@/views/management/wellcondition.vue'),
            meta: { title: '井况管理' }
          },
          {
            path: '/export',
            name:'export',
            component: () => import(/* webpackChunkName: "export" */'@/views/management/export/export.vue'),
            meta: { title: '数据导出' }
          },
          {
            path: '/import',
            name:'import',
            component: () => import(/* webpackChunkName: "import" */'@/views/management/import/import.vue'),
            meta: { title: '数据导入' }
          },
          {
            path: '/monitoring',
            name:'monitoring',
            component: () => import(/* webpackChunkName: "monitoring" */'@/views/management/monitoring/monitoring.vue'),
            meta: { title: '监控管理' }
          }
        ]
    },
    {
      path: '/',
      name: 'LogManagement',
      component: () => import(/* webpackChunkName: "templates" */'@/views/homepage.vue'),
      meta: { title: '日志管理'},
      children: [
      {
        path: '/log',
        name:'log',
        component: () => import(/* webpackChunkName: "log" */'@/views/management/log/log.vue'),
        meta: { title: '操作日志' }
      },
      {
        path: '/loganalysis',
        name:'loganalysis',
        component: () => import(/* webpackChunkName: "loganalysis" */'@/views/management/log/loganalysis.vue'),
        meta: { title: '日志分析' }
      }
      ]
    },
    {
      path: '/',
      name: 'AuthorityManagement',
      component: () => import(/* webpackChunkName: "homepage" */'@/views/homepage.vue'),
      meta: { title: '权限管理' },
      children: [
        {
          path: '/menu',
          name:'menu',
          component: () => import(/* webpackChunkName: "menu" */'@/views/management/authority/menu.vue'),
          meta: { title: '菜单管理' }
        },
        {
          path: '/userinfo',
          name:'userinfo',
          component: () => import(/* webpackChunkName: "userinfo" */'@/views/management/authority/userinfo.vue'),
          meta: { title: '用户信息' }
        },
        {
          path: '/usergroupinfo',
          name:'usergroupinfo',
          component: () => import(/* webpackChunkName: "usergroupinfo" */'@/views/management/authority/usergroupinfo.vue'),
          meta: { title: '用户组信息' }
        },
        {
          path: '/role',
          name:'role',
          component: () => import(/* webpackChunkName: "role" */'@/views/management/authority/role.vue'),
          meta: { title: '角色管理' }
        },
        {
          path: '/roleauthority',
          name:'roleauthority',
          component: () => import(/* webpackChunkName: "roleauthority" */'@/views/management/authority/roleauthority.vue'),
          meta: { title: '角色权限分配' }
        },
        {
          path: '/userRoleauthority',
          name:'userRoleauthority',
          component: () => import(/* webpackChunkName: "userRoleauthority" */'@/views/management/authority/userRoleauthority.vue'),
          meta: { title: '用户权限分配' }
        }
      ]
    },
    {
      path: '/',
      name: 'DocumentManagement',
      component: () => import(/* webpackChunkName: "templates" */'@/views/homepage.vue'),
      meta: { title: '文档管理'},
      children: [
      {
        path: '/welldaily',
        name:'welldaily',
        component: () => import(/* webpackChunkName: "welldaily" */'@/views/management/document/welldaily.vue'),
        meta: { title: '钻井日报' }
      },
      {
        path: '/geologydaily',
        name:'geologydaily',
        component: () => import(/* webpackChunkName: "geologydaily" */'@/views/management/document/geologydaily.vue'),
        meta: { title: '地质日报' }
      },
      {
        path: '/slurrydaily',
        name:'slurrydaily',
        component: () => import(/* webpackChunkName: "slurrydaily" */'@/views/management/document/slurrydaily.vue'),
        meta: { title: '泥浆日报' }
      }
      ]
    },
    {
      path: '/',
      name: 'ConfigurationSheetManagement',
      component: () => import(/* webpackChunkName: "templates" */'@/views/homepage.vue'),
      meta: { title: '配置单管理'},
      children: [
      {
        path: '/wellsetlist',
        name:'wellsetlist',
        component: () => import(/* webpackChunkName: "wellsetlist" */'@/views/management/setlist/wellsetlist.vue'),
        meta: { title: '测井配置单' } 
      }
      ]
    },

    {
      path: '/login',
      name:'login',
      component: () => import(/* webpackChunkName: "login" */'@/views/login.vue'),
      meta: { title: '登录' }
    },
    {
      path: '/404',
      name:'404',
      component: () => import(/* webpackChunkName: "404" */'@/views/other/404.vue'),
      meta: { title: '404页面' }
    },
    // {
    //   path: '*',
    //   redirect: '/404'
    // }
  ]
})
// 导航守卫
// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
router.beforeEach((to, from, next) => {
  if (to.path === '/login') {
    next();
  } else {
    let token = localStorage.getItem('Authorization');
    if (token === null || token === '') {
      alert("未登录,请先登录！")
      next('/login');
    } else {
      next();
    }
  }
});
export default router;

